const FileRagService = require('./fileRag');
const WebRagService = require('./webRag');
const GithubRagService = require('./githubRag');

class RagService {
  static async init() {
    try {
      // 初始化所有RAG服务
      const services = [
        { name: 'FileRag', service: FileRagService },
        { name: 'WebRag', service: WebRagService },
        { name: 'GithubRag', service: GithubRagService }
      ];

      for (const { name, service } of services) {
        try {
          console.log(`正在初始化${name}服务...`);
          await service.initializeData();
          console.log(`${name}服务初始化成功`);
        } catch (error) {
          console.error(`${name}服务初始化失败:`, error);
          throw new Error(`${name}服务初始化失败: ${error.message}`);
        }
      }

      console.log('所有RAG服务初始化完成');
    } catch (error) {
      console.error('RAG服务初始化过程中发生错误:', error);
      throw error;
    }
  }
}

module.exports = {
  RagService,
  FileRagService,
  WebRagService,
  GithubRagService
};